package hongcaosp.app.android.modle.impl;

import android.text.TextUtils;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpParams;

import hongcaosp.app.android.BuildConfig;
import hongcaosp.app.android.modle.BaseResponse;
import hongcaosp.app.android.modle.DataCallBack;
import hongcaosp.app.android.modle.mi.LoginModle;
import hongcaosp.app.android.modle.bean.UserInfoWrap;

public class LoginModleImpl implements LoginModle {
    @Override
    public void login(String mobile, String verificationCode, String password, String code, int type, DataCallBack<UserInfoWrap> dataCallBack) {
        HttpParams params = new HttpParams();
        if (!TextUtils.isEmpty(mobile)) {
            params.put("mobile", mobile);
        }
        if (!TextUtils.isEmpty(verificationCode)) {
            params.put("verificationCode", verificationCode);
        }
        if (!TextUtils.isEmpty(password)) {
            params.put("password", password);
        }
        if (!TextUtils.isEmpty(code)) {
            params.put("loginCode", code);
        }
        params.put("type", type);
        OkGo.<BaseResponse>post(BuildConfig.HOST + "/api/userLogin").params(params).execute(dataCallBack);
    }

    @Override
    public void register(String mobile, String verificationCode, String inviteCode, DataCallBack<BaseResponse> dataCallBack) {
        HttpParams params = new HttpParams();
        params.put("mobile", mobile);
        params.put("verificationCode", verificationCode);
        params.put("inviteCode", inviteCode);
        OkGo.<BaseResponse>post(BuildConfig.HOST + "/api/userRegister").params(params).execute(dataCallBack);
    }
}
